package com.group.yztcedu.playlive.main.me.View;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.group.yztcedu.playlive.R;
import com.group.yztcedu.playlive.bean.MyDataBean;

import java.util.List;

/**
 * Created by Administrator on 2016/8/17.
 */
public class MyAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private List<MyDataBean> list;
    private Context context;
    public MyAdapter(List<MyDataBean> list,Context mContext) {
        context = mContext;
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list != null ? list.size() : 0;
    }

    @Override
    public Object getItem(int i) {
        return list != null ? list.get(i) : null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Viewholder viewholder;
        if (view == null) {
            view = mInflater.inflate(R.layout.me_follow_listview_item, viewGroup, false);
            viewholder = new Viewholder(view);
            view.setTag(viewholder);
        }
        viewholder = (Viewholder) view.getTag();
        viewholder.layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                    startActivity(new Intent(MeFollowActivity.this,));
            }
        });
        Glide.with(context).load(list.get(i).getHeaduri()).into(viewholder.headlogo);
        viewholder.tv_name.setText(list.get(i).getUsername());
        viewholder.tv_count.setText(list.get(i).getUserfollowcount());
        return view;
    }

    public class Viewholder {
        private RelativeLayout layout;
        private ImageView headlogo;
        private TextView tv_name;
        private TextView tv_count;

        Viewholder(View view) {
            headlogo = (ImageView) view.findViewById(R.id.me_follow_head_logo);
            tv_name = (TextView) view.findViewById(R.id.me_follow_head_name);
            layout = (RelativeLayout) view.findViewById(R.id.me_follow_list_item);
            tv_count = (TextView) view.findViewById(R.id.me_follow_head_nub);

        }
    }
}
